tests/gpg: Use exit hook to kill agent in temporary GPG homedir
authorDan Nicholson <nicholson@endlessm.com>
Fri, 26 Jul 2019 16:17:07 +0000 (10:17 -0600)
committerAtomic Bot <atomic-devel@projectatomic.io>
Sat, 27 Jul 2019 03:20:21 +0000 (03:20 +0000)
This wasn't available when I originally wrote this, but it ensures that
the running gpg-agent in tmpgpghome is killed in case the tests exit
early.

Closes: #1892
Approved by: jlebon

tests/test-gpg-signed-commit.sh

index 3e41efb82ceacd9a7a4c60dc8d9c305ed300a9f5..2fc2cf2f956be9aceb27d5bf3bf032b8bd3d6732 100755 (executable)
@@ -100,6 +100,12 @@ fi
 tmpgpg_home=${test_tmpdir}/tmpgpghome
 mkdir -m700 ${tmpgpg_home}
 
+# Wire up an exit hook to kill the gpg-agent in it
+cleanup_tmpgpg_home() {
+  libtest_cleanup_gpg ${tmpgpg_home}
+}
+libtest_exit_cmds+=(cleanup_tmpgpg_home)
+
 # Create an temporary trusted GPG directory
 tmpgpg_trusted=${test_tmpdir}/tmpgpgtrusted
 tmpgpg_trusted_keyring=${tmpgpg_trusted}/keyring.gpg
@@ -301,5 +307,3 @@ if [ -f ${key1_rev} ]; then
 else
   echo "ok # SKIP could not find key revocation certificate"
 fi
-
-libtest_cleanup_gpg ${tmpgpg_home}